package com.tptech.nearme.data;

import javax.management.Query;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;

import com.tptech.nearme.model.Location;


public class LocationRepository extends BaseRepository<Location>{

	public LocationRepository() {
		super(Location.class);
	}



	
	public Location merge(Location location) {
		EntityManager manager = getEntityManager();
		TypedQuery<Location> locationQuery = manager.createNamedQuery("location.similarLocation", Location.class);
		locationQuery.setParameter("p",location);
		Location l= locationQuery.getSingleResult();
		if(l==null){
			save(location);
			l=location;
		}
		return l;
	}

}
